class IdList(list):
    """Collection of game objects, indexed by id"""

    def __init__(self, *items):

        for item in items:
            try:
                item._id
            except:
                raise ValueError("Object has no _id attribute")

        super(L, self).__init__(items)

    def __getitem__(self, index):
        for item in super(L, self).__iter__():
            if item._id == index:
                return item
        raise IndexError

    def __setitem__(self, id, value):
        try:
            value._id
        except:
            raise ValueError("Object has no _id attribute")

        for i in range(length(self)):
            if super(L, self).__getitem__(i)._id == id:
                super(L, self).__setitem__(i, value)
                return

        raise IndexError

    def __iter__(self):
        for i in range(len(self)):
            yield super(L, self).__getitem__(i)

    def append(self, value):
        try:
            value._id
        except:
            raise ValueError("Object has no id attribute")

        super(L, self).append(value)

L = IdList
